<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateAdminsTable extends Migration
{
    /**
     * 管理员
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 管理员表
        Schema::create('admins', function (Blueprint $table) {
            $table->bigIncrements('id')->comment('ID');
            $table->uuid('uuid')->comment('UUID');
            $table->unsignedBigInteger('parent_id')->default(0)->comment('父级ID');
            $table->string('avatar')->nullable()->comment('头像');
            $table->string('qr_code')->nullable()->comment('二维码');
            $table->string('nickname', 100)->comment('昵称');
            $table->string('title')->default('')->comment('头衔');
            $table->tinyInteger('gender')->default(1)->comment('性别[1:男,2:女]');
            $table->string('mobile')->nullable()->unique()->comment('手机');
            $table->string('email')->nullable()->unique()->comment('邮箱');
            $table->timestamp('email_verified_at')->nullable()->comment('邮箱验证时间');
            $table->string('password')->comment('密码');
            $table->tinyInteger('status')->default(0)->comment('状态[0:激活,1:锁定]');;
            $table->timestamp('last_login_at')->nullable()->comment('最后登录时间');
            $table->string('last_login_ip')->nullable()->comment('最后登录IP');
            $table->string('last_login_city')->nullable()->comment('最后登录城市');
            $table->integer('login_count')->default('0')->comment('登录次数');
            $table->rememberToken()->comment('记住密码');
            $table->timestamp('created_at')->nullable()->comment('创建时间');
            $table->timestamp('updated_at')->nullable()->comment('修改时间');
            $table->bigInteger('created_admin_id')->default(0)->comment('创建人');
            $table->bigInteger('updated_admin_id')->default(0)->comment('修改人');
        });

        DB::statement('alter table' . ' ' . config('database.connections.mysql.prefix', '') . 'admins comment "管理员表"');
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('admins');     // 管理员表
    }
}
